<%@ Page Language="VB" MasterPageFile="~/masterpages/MasterPrivate.master" AutoEventWireup="false"
    CodeFile="competenciasEvidencias.aspx.vb" Inherits="admin_competenciasEvidencias" Title="Mantenimiento de Competencias" Culture="auto"
    meta:resourcekey="PageResource1" UICulture="auto" EnableEventValidation = "false" %>
<%@ Register Assembly="RadWindow.Net2" Namespace="Telerik.WebControls" TagPrefix="radW" %>
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PrivateWorkArea" runat="Server">
    <table cellpadding="0" cellspacing="0" border="0" width="98%" align="center">
        <tr valign="top">
           <td>
                <div class="bgpanel_title"><asp:Label ID="lblTituloForm" runat="server" Text="<%$ Resources:lblTituloForm %>"></asp:Label></div>
                <br />
                <asp:Label ID="lblSeleccioneCliente" runat="server" Text="<%$ Resources:lblSeleccioneCliente %>" SkinID="LiteralesVerdeOscuro"></asp:Label>
                <asp:DropDownList ID="dropClientes" runat="server" AppendDataBoundItems="True" SkinID="DropDown" AutoPostBack="True"
                 DataSourceID="SqlDataSourceClientes" 
                 DataTextField="NombreCliente" 
                 DataValueField="IdCliente"
                 OnSelectedIndexChanged="dropClientes_SelectedIndexChanged">
                </asp:DropDownList>    
                <br /><br /> 
                           
                <div class="bgpanelFV">
                    <radG:RadGrid ID="RadGrid1" runat="server"
                                  Skin="Office2007"
                                  DataSourceID="SqlDataSourceCompetencias"
                                  AutoGenerateColumns="False"
                                  AllowMultiRowSelection="False"
                                  Width="100%"
                                  AllowSorting="True"
                                  AllowPaging="True"
                                  PageSize="20"
                                  AllowMultiRowEdit="False"
                                  GroupingEnabled="False"
                                  ShowGroupPanel="False"
                                  AllowFilteringByColumn="False"
                                  EnableAJAX="True"
                                  EnableAJAXLoadingTemplate="True"                                   
                                  GridLines="None"
                                  AllowAutomaticDeletes="True"
                                  OnItemDeleted="RadGrid1_ItemDeleted"
                                  AllowAutomaticInserts="True"
                                  OnItemInserted="RadGrid1_ItemInserted"
                                  AllowAutomaticUpdates="True"
                                  OnItemUpdated="RadGrid1_ItemUpdated"
                                  GroupingSettings-ExpandTooltip="<%$ Resources:GridGroupingExpandToolTip %>"
                                  GroupingSettings-CollapseTooltip="<%$ Resources:GridGroupingCollapseToolTip %>"                                  
                                  HierarchySettings-ExpandTooltip="<%$ Resources:GridGroupingExpandToolTip %>"
                                  HierarchySettings-CollapseTooltip="<%$ Resources:GridGroupingCollapseToolTip %>"
                                  SortingSettings-SortToolTip="<%$ Resources:GridSortToolTip %>"
                                  SortingSettings-SortedAscToolTip="<%$ Resources:GridSortedAscToolTip %>"
                                  SortingSettings-SortedDescToolTip="<%$ Resources:GridSortedDescToolTip %>"
                                  ActiveItemStyle-Font-Bold="True"
                                  LicenseFile="~/RadControls/LicenseFile.xml"
                                  >
                        <PagerStyle Mode="NumericPages" PagerTextFormat="<%$ Resources:GridPagerTextFormat %>" AlwaysVisible="False" CssClass="GridPager_Office2007" />                                              
                        <ClientSettings ReorderColumnsOnClient="False" AllowColumnsReorder="False" Selecting-AllowRowSelect="True">
                            <Resizing AllowRowResize="False" ClipCellContentOnResize="False" AllowColumnResize="False">
                            </Resizing>
                            <ClientMessages DragToResize="<%$ Resources:GridDragToResize %>"  />                           
                        </ClientSettings>
                                                
                        <MasterTableView DataSourceID="SqlDataSourceCompetencias" DataKeyNames="idCompetencia" AllowMultiColumnSorting="True" CommandItemDisplay="Top" HorizontalAlign="NotSet" AutoGenerateColumns="False" ShowHeadersWhenNoRecords="True">
                           <NoRecordsTemplate>
                                <asp:Label ID="lblMasterNoRecords" runat="server" Text="<%$ Resources:GridMasterNoRecords %>"></asp:Label>                               
                           </NoRecordsTemplate>                           
                           <CommandItemTemplate>
                                  <table width="100%">
                                   <tr>
                                    <td style="width:30%">
                                     <asp:Button ID="btnAdd" CssClass="BtnGridAnyadir" Text="<%$ Resources:GridMasterCommandItemAdd %>" CommandName="InitInsert" Runat="server"></asp:Button>
                                    </td>
                                    <td style="width:40%">
                                    </td>
                                    <td style="width:30%; text-align:right">
                                     <asp:Button ID="btnRefresh" CssClass="BtnGridRefrescar" Text="<%$ Resources:GridMasterCommandItemRefresh %>" CommandName="Rebind" Runat="server"></asp:Button>
                                    </td>
                                   </tr>
                                  </table>
                            </CommandItemTemplate>
                            <Columns>
                                <radg:GridEditCommandColumn ButtonType="ImageButton" UpdateImageUrl="..\Images\ImgGrids\Update.gif" EditImageUrl="..\Images\ImgGrids\Edit.gif" InsertImageUrl="..\Images\ImgGrids\Insert.gif" CancelImageUrl="..\Images\ImgGrids\Cancel.gif" UniqueName="EditCommandColumn" EditText="<%$ Resources:GridEditCommandEdit %>" UpdateText="<%$ Resources:GridEditCommandUpdate %>" CancelText="<%$ Resources:GridEditCommandCancel %>">
                                    <HeaderStyle Width="20px" />
                                    <ItemStyle CssClass="ImageBtnPointer" />                        
                                </radg:GridEditCommandColumn>                            
                                <radG:GridBoundColumn UniqueName="idCompetencia" DataField="idCompetencia" HeaderText="ID" ReadOnly="True" Visible="False">
                                </radG:GridBoundColumn>                                
                                <radG:GridBoundColumn UniqueName="idCliente" DataField="idCliente" HeaderText="" ReadOnly="True" Visible="False">
                                </radG:GridBoundColumn>                                
                                <radG:GridBoundColumn UniqueName="DescripcionCorta" SortExpression="DescripcionCorta" HeaderText="<%$ Resources:GridMasterHeaderCompetencia %>" DataField="DescripcionCorta" Visible="True">
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn UniqueName="DescripcionLarga" SortExpression="DescripcionLarga" HeaderText="s" DataField="DescripcionLarga" Visible="false">
                                </radG:GridBoundColumn>                                
                                <radG:GridButtonColumn ConfirmText="<%$ Resources:GridMasterButtonDeleteConfirm %>" ButtonType="ImageButton" ImageUrl="..\Images\ImgGrids\Delete.gif" CommandName="Delete" Text="<%$ Resources:GridMasterButtonDeleteText %>" UniqueName="DeleteColumn">
                                    <HeaderStyle Width="20px" />
                                    <ItemStyle HorizontalAlign="Center" CssClass="ImageBtnPointer" />
                                </radG:GridButtonColumn>
                            </Columns>

                           <EditFormSettings EditFormType="Template">
                            <EditColumn UniqueName="idCompetencia1"></EditColumn>
                            <FormTemplate>
                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" HeaderText="<%$ Resources:ValidationSummaryMsg %>" />
                                <table id="Table1" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none" class="EditForm">
	                                <tr class="EditFormHeader">
		                                <td><asp:Label ID="lblMasterEditHeader" runat="server" Text="<%$ Resources:GridMasterEditHeader %>" SkinID="SubtituloDetail"></asp:Label></td>
	                                </tr>
	                                <tr>
		                                <td>
			                                <table id="Table3" cellspacing="1" cellpadding="1" width="100%" border="0" class="module" align="center">
				                                <tr>
					                                <td align="right" width="20%">
                                                        <asp:Label ID="lblCompetencia" runat="server" Text="<%$ Resources:lblEditCompetencia %>" SkinID="LiteralesVerdeOscuro"></asp:Label>
                                                    </td>
					                                <td align="left">
						                                <asp:TextBox id="DescripcionCorta" runat="server" SkinID="Campos" Width="90%"
						                                Text='<%# Bind( "DescripcionCorta" ) %>'>
						                                </asp:TextBox>
						                                <asp:RequiredFieldValidator ID="rfvDescripcionCorta" runat="server" ControlToValidate="DescripcionCorta" Display="Dynamic" Text="*"></asp:RequiredFieldValidator>
						                            </td>
				                                </tr>
				                                <tr>
					                                <td align="right" width="20%"><asp:Label ID="Label2" runat="server" Text="<%$ Resources:lblEditFunciones %>" SkinID="LiteralesVerdeOscuro"></asp:Label></td>
					                                <td align="left">
						                                <asp:TextBox id="DescripcionLarga" runat="server" TextMode="MultiLine" SkinID="CamposMultiLine" Width="90%" Height="150%"
						                                Text='<%# Bind( "DescripcionLarga" ) %>'>
						                                </asp:TextBox>
						                                <asp:RequiredFieldValidator ID="rfvDescripcionLarga" runat="server" ControlToValidate="DescripcionLarga" Display="Dynamic" Text="*"></asp:RequiredFieldValidator>
					                                </td>
				                                </tr>
			                                </table>
		                                </td>
	                                </tr>
	                                <tr>
		                                <td align="left" colspan="2">
		                                    <asp:button id="btnGrabar" text='<%$ Resources:GridFormTemplateSave %>' CssClass="BtnGrabar"
                                                runat="server" CommandName='<%# IIf(CType(Container,GridItem).OwnerTableView.IsItemInserted ,"PerformInsert","Update") %>'>		                                
		                                    </asp:button>&nbsp;                                                        
		                                    <asp:button id="Button3" text="  <%$ Resources:GridFormTemplateCancel %>" runat="server" CommandName="Cancel" causesvalidation="False" CssClass="BtnCancelar"></asp:button>                                                        
		                                </td>
	                                </tr>	
                                </table>						                            
                            </FormTemplate>                            
                           </EditFormSettings>                           
                           <SortExpressions>
                                <radG:GridSortExpression FieldName="DescripcionCorta" />
                           </SortExpressions>
                           <DetailTables>
                                <radG:GridTableView DataSourceID="SqlDataSourceEvidencias" DataKeyNames="idEvidencia" AllowMultiColumnSorting="True" CommandItemDisplay="Top" HorizontalAlign="NotSet" AutoGenerateColumns="False" Width="100%" runat="server" BorderStyle="outset" BorderColor="#858E6A" BorderWidth="3" ShowHeadersWhenNoRecords="True">
                                    <ParentTableRelation>
                                        <radG:GridRelationFields DetailKeyField="idCompetencia" MasterKeyField="idCompetencia" />
                                    </ParentTableRelation>
                                    <NoRecordsTemplate>
                                        <asp:Label id="lblDetailsNoRecords" runat="server" Text="<%$ Resources:GridDetailsNoRecords %>"></asp:Label>
                                    </NoRecordsTemplate>
                                    <CommandItemTemplate>
                                          <table width="100%">
                                           <tr>
                                            <td style="width:30%">
                                             <asp:Button ID="btnAddEvidencia" CssClass="BtnGridAnyadir" Text="<%$ Resources:GridDetailsCommandItemAdd %>" CommandName="InitInsert" Runat="server"></asp:Button>
                                            </td>
                                            <td style="width:40%">
                                            </td>
                                            <td style="width:30%; text-align:right">
                                             <asp:Button ID="btnRefreshEvidencias" CssClass="BtnGridRefrescar" Text="<%$ Resources:GridDetailsCommandItemRefresh %>" CommandName="Rebind" Runat="server"></asp:Button>
                                            </td>
                                           </tr>
                                          </table>
                                    </CommandItemTemplate>
                                    <Columns>                                        
                                        <radg:GridEditCommandColumn ButtonType="ImageButton" UpdateImageUrl="..\Images\ImgGrids\Update.gif" EditImageUrl="..\Images\ImgGrids\Edit.gif" InsertImageUrl="..\Images\ImgGrids\Insert.gif" CancelImageUrl="..\Images\ImgGrids\Cancel.gif" UniqueName="EditCommandDetailColumn" EditText="<%$ Resources:GridEditCommandEdit %>" UpdateText="<%$ Resources:GridEditCommandUpdate %>" CancelText="<%$ Resources:GridEditCommandCancel %>">
                                            <HeaderStyle Width="40px" /> 
                                            <ItemStyle HorizontalAlign="Right" CssClass="ImageBtnPointer" />
                                        </radg:GridEditCommandColumn> 
                                        <radG:GridBoundColumn UniqueName="idCompetencia" DataField="idCompetencia" HeaderText="" ReadOnly="True" Visible="False">
                                        </radG:GridBoundColumn>                            
                                        <radG:GridBoundColumn UniqueName="idEvidencia" DataField="idEvidencia" HeaderText="ID" ReadOnly="True" Visible="False">
                                        </radG:GridBoundColumn>                                
                                        <radG:GridBoundColumn UniqueName="Descripcion" SortExpression="Descripcion" HeaderText="<%$ Resources:GridDetailsHeaderEvidencia %>" DataField="Descripcion" Visible="True" ReadOnly="False">
                                        </radG:GridBoundColumn>
                                        <radG:GridButtonColumn ConfirmText="<%$ Resources:GridDetailsButtonDeleteConfirm %>" ButtonType="ImageButton" ImageUrl="..\Images\ImgGrids\Delete.gif" CommandName="Delete" Text="<%$ Resources:GridDetailsButtonDeleteText %>" UniqueName="DeleteDetailColumn">
                                            <HeaderStyle Width="20px" />
                                            <ItemStyle HorizontalAlign="Center" CssClass="ImageBtnPointer" />
                                        </radG:GridButtonColumn>
                                    </Columns>                                  
                                    <SortExpressions>
                                        <radG:GridSortExpression FieldName="Descripcion" SortOrder="Ascending"></radG:GridSortExpression>
                                    </SortExpressions> 
                                    <EditFormSettings EditFormType="Template">
                                        <EditColumn UniqueName="idEvidencia"></EditColumn>
                                        <FormTemplate>
                                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" HeaderText="<%$ Resources:ValidationSummaryMsg %>" />
                                            <table id="Table4" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none" class="EditForm" style="margin-left:40px">
	                                            <tr class="EditFormHeader">
		                                            <td><asp:Label ID="lblEditHeader" runat="server" Text="<%$ Resources:GridDetailsEditHeader %>" SkinID="SubtituloDetail"></asp:Label></td>
	                                            </tr>
	                                            <tr>		                                            
		                                            <td>
			                                            <table id="Table5" cellspacing="1" cellpadding="1" width="100%" border="0" class="module" align="center">
				                                            <tr>
					                                            <td align="right" width="20%">
                                                                    <asp:Label ID="lblEvidencia" runat="server" Text="<%$ Resources:lblEditEvidencia %>" SkinID="LiteralesVerdeOscuro"></asp:Label>
                                                                </td>
					                                            <td align="left">
						                                            <asp:TextBox id="Descripcion" runat="server" SkinID="Campos" Width="90%"
						                                            Text='<%# Bind( "Descripcion" ) %>'>
						                                            </asp:TextBox>
						                                            <asp:RequiredFieldValidator ID="rfvDescripcion" runat="server" ControlToValidate="Descripcion" Display="Dynamic" Text="*"></asp:RequiredFieldValidator>
						                                        </td>
				                                            </tr>
			                                            </table>
		                                            </td>
	                                            </tr>
	                                            <tr>	                                                
		                                            <td align="left">
		                                                <asp:button id="btnGrabarEvidencia" text='<%$ Resources:GridFormTemplateSave %>' CssClass="BtnGrabar"
                                                            runat="server" CommandName='<%# IIf(CType(Container,GridItem).OwnerTableView.IsItemInserted ,"PerformInsert","Update") %>'>		                                
		                                                </asp:button>&nbsp;                                                        
		                                                <asp:button id="btnCancelarEvidencia" text="  <%$ Resources:GridFormTemplateCancel %>" runat="server" CommandName="Cancel" causesvalidation="False" CssClass="BtnCancelar"></asp:button>                                                        
		                                            </td>
	                                            </tr>	
	                                            <asp:TextBox id="txtidCompetencia" runat="server" SkinID="Campos" Text='<%# Bind( "idCompetencia" ) %>' Visible="False">
						                        </asp:TextBox>
                                            </table>
                                            
                                        </FormTemplate>
                                        
                                       </EditFormSettings>                                    
                                                                       
                                </radG:GridTableView>
                           </DetailTables> 
                        </MasterTableView>
                        
                        <AJAXLoadingTemplate>
                            <img src="../images/LoadingProgressBar.gif" alt="Cargando Datos" align="middle" />
                        </AJAXLoadingTemplate>                        
                    </radG:RadGrid>
                </div>
                <div class="bgpanel_bottom">
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td style="width: 85px" valign="top">
                                <asp:Image ID="imgButtonIconDocuments" runat="server" ImageUrl="../images/button_icon_documents.gif"
                                    Height="57px" meta:resourcekey="imgButtonIconUsersResource1" />
                            </td>
                            <td align="left" valign="top" class="bgpanel_buttons">
                            </td>
                            <td align="right" valign="top" class="bgpanel_buttons">
                            </td>
                        </tr>
                    </table>
                </div>                    
           </td>
        </tr>
    </table> 
    <asp:Label ID="LabelError" runat="server" Text="" SkinID="AdvertenciaGris"></asp:Label>              
    
    
        <asp:SqlDataSource ID="SqlDataSourceCompetencias" runat="server" ConnectionString="<%$ ConnectionStrings:EviMaster %>"
            SelectCommand="spCompetenciasGetAll" SelectCommandType="StoredProcedure"
            DeleteCommand="spCompetenciasDelete" DeleteCommandType="StoredProcedure"
            UpdateCommand="spCompetenciasUpdate" UpdateCommandType="StoredProcedure"
            InsertCommand="spCompetenciasAdd" InsertCommandtype="StoredProcedure">
            <SelectParameters>
                <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
            </SelectParameters>
            <DeleteParameters>
              <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
              <asp:Parameter Name="idCompetencia" Type="Object" />
            </DeleteParameters>        
            <UpdateParameters>
              <asp:Parameter Name="idCompetencia"/>
              <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
              <asp:Parameter Name="DescripcionCorta" Type="string"/>
              <asp:Parameter Name="DescripcionLarga" Type="string"/>
            </UpdateParameters>        
            <InsertParameters>              
              <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
              <asp:Parameter Name="DescripcionCorta" Type="string"/>
              <asp:Parameter Name="DescripcionLarga" Type="string"/>
            </InsertParameters>        
        </asp:SqlDataSource>
        
        <asp:SqlDataSource ID="SqlDataSourceEvidencias" runat="server" ConnectionString="<%$ ConnectionStrings:EviMaster %>"
            SelectCommand="SELECT * From [vw_evi_Evidencias] Where (idCompetencia = @idCompetencia) And (idCliente = @idCliente)"
            DeleteCommand="spEvidenciasDelete" DeleteCommandType="StoredProcedure"
            UpdateCommand="spEvidenciasUpdate" UpdateCommandType="StoredProcedure"
            InsertCommand="spEvidenciasAdd" InsertCommandtype="StoredProcedure">
            <SelectParameters>
                <asp:SessionParameter Name="idCompetencia" SessionField="idCompetencia" />
                <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
            </SelectParameters>
            <DeleteParameters>
              <asp:Parameter Name="idEvidencia"/>
              <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
            </DeleteParameters> 
            <UpdateParameters>
              <asp:Parameter Name="idEvidencia"/>
              <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
              <asp:Parameter Name="idCompetencia"/>
              <asp:Parameter Name="Descripcion" Type="string"/>
            </UpdateParameters>        
            <InsertParameters> 
              <asp:Parameter Name="idCompetencia"/> 
              <asp:ControlParameter ControlID="dropClientes" Name="idCliente" />
              <asp:Parameter Name="Descripcion" Type="string"/>
            </InsertParameters>                   
        </asp:SqlDataSource> 
        
        <asp:SqlDataSource ID="SqlDataSourceClientes" runat="server" ConnectionString="<%$ ConnectionStrings:EviMaster %>"
             SelectCommand="spClientesGetAll" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource> 
                   
        <asp:Label ID="ErrorMessageLabel" EnableViewState="False" runat="server" meta:resourcekey="ErrorMessageLabelResource1" />
</asp:Content>